using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Diagnostics;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string test = "Testing 1-2-3";
        byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(test);
        System.IO.MemoryStream stream = new System.IO.MemoryStream(byteArray);
        stream.Flush();
        stream.Close();
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "text/plain";
        Response.AddHeader("content-disposition", "attachment;filename=StandardTxtReport.txt");
        Response.BinaryWrite(stream.ToArray());
        Response.Flush();
        //ClientScript.RegisterClientScriptBlock(GetType(), "Delay", "<script type='text/javascript'> alert('Close JavaScript Delay Screen!');</script>");
        Response.End();
        //RunScript();
    }

    private void RunScript()
    {
        Process scriptProcess = new Process();
        scriptProcess.StartInfo.FileName = "cscript.exe";
        scriptProcess.StartInfo.Arguments = "C:\\test.vbs";
        scriptProcess.StartInfo.UseShellExecute = false;

        try
        {
            scriptProcess.Start();
            scriptProcess.WaitForExit();
        }
        catch (Exception ex)
        {
            String s = ex.Message;
        }
    }
}
